<?php
/**
 * @package WordPress
 * @subpackage WelCare
 */
get_header();
$queried_obj = get_queried_object();
/** blog settings from option  */ ?>

<div class="container"> 
	
	<!-- Page Banner -->
	<?php fw_subpages_banner('page'); ?>
	
	<!-- BreadCrumbs -->
	<div class="breadcrumbs"> <?php echo get_the_breadcrumb(); /** add breadcrumbs */?> </div>
	
        <?php $sidebar = get_post_meta($queried_obj->ID, 'wl_custom_sidebar', true); 
		//echo $sidebar ; exit ; 
	$contents_area = ( $sidebar != -1) ? 'contents_area' : '';
	$contents = ( $sidebar != -1) ? 'contents' : '';
	?>

	<!--Content Area -->
	<div id="<?php echo $contents_area; ?>">
		<div class="<?php echo $contents; ?>">
			<?php if (have_posts()) : /** start our loop  */ ?>
			<?php while (have_posts()) : the_post(); ?>
			<article>
				<div class="head_section">
                	<?php if( $sidebar ):?>
					<div class="post_date">
						<div class="day_month"> <span class="day">
							<?php the_time('d'); ?>
							</span> <span class="month">
							<?php the_time('M'); ?>
							</span> </div>
						<span class="post_year">
						<?php the_time('Y'); ?>
						</span> 
                    </div>
                    <?php endif;?>
					<h1>
						<?php the_title();?>
					</h1>
                    <?php if(get_post_meta($post->ID, 'wl_post_meta', true)):?>
					<div class="contact_bar">
						<ul>
							<li class="first-child"><a class="doctor_icon" href="<?php echo HOME_URL ?>?author=<?php the_author_meta( 'ID' ) ?>">
								<?php the_author();?>
								</a></li>
							<li class="comments_icon">
								<?php comments_popup_link(  __( '0 Comments', THEME_NAME ), __( '1 Comment', THEME_NAME ), __( '% Comments', THEME_NAME ) ); ?>
							</li>
						</ul>
					</div>
                    <?php endif;?>
				</div>
				<?php /** get post image id */ ?>
				<?php if(has_post_thumbnail()) the_post_thumbnail('single-image', array('class'=>'frame')); ?>
				<div class="details">
					<?php the_content(); ?>
					<?php wp_link_pages( 'before=<div class="paginate"><span class="page_numbering">'.__( 'Pages:', THEME_NAME ) .'</span>&after=</div>' ); ?>
				</div>
			</article>
			<?php endwhile;?>
			
			<!-- Comments -->
				<?php if(comments_open()):?>
                <?php comments_template('', true); /** print comments and comment form */?>
                <?php endif;?>
			<?php endif;?>
		</div>
	</div>
	
    <?php if( $sidebar != -1): ?>
	<!--Sidebar-->
	<div id="side_bar">
		<?php if($sidebar = get_post_meta($post->ID, 'wl_custom_sidebar', true)) dynamic_sidebar($sidebar);
			else _load_dynamic_sidebar('page', 'blog-sidebar'); ?>
	</div>
    <?php endif; ?>
</div>
<?php get_footer(); ?>
